强度削弱(strength reduction):编译器优化中的一种方法,把“计算代价高”的运算替换为“代价更低但等价”的运算,从而加快程序运行(常见于循环中)。例如用加法/移位代替乘法,用递推更新代替重复计算。此术语也可泛指在算法或实现中用更便宜的操作替换更昂贵的操作。
/streŋθ rɪˈdʌkʃən/
We applied strength reduction to replace multiplication with addition inside the loop.
我们对循环内的乘法做了强度削弱,用加法替代。
In the compiler’s intermediate representation, strength reduction can transform repeated address calculations into incremental updates, improving performance without changing results.
在编译器的中间表示中,强度削弱可以把重复的地址计算改写为递增更新,在不改变结果的前提下提升性能。
strength 原意是“力量、强度”,在优化语境中可理解为“运算强度/代价”;reduction 是“减少、降低”。合起来就是“降低运算的强度(成本)”。这一说法在早期编译器优化研究与教材中被固定下来,用来描述“用更便宜的指令替换更昂贵的指令”的转换策略。